<template>
  <view>
    <view>
      age：{{age}}
    </view>
    <view>
      <button @click="updateAge">updateAge</button>
    </view>
    <view>
      username：{{username}}
    </view>
    <view>
      <button @click="updateUsername">updateUsername</button>
    </view>
    <view>
      <button @click="update">update</button>
    </view>
  </view>
</template>

<script lang="ts">
import Vue from 'vue'
import { mapMutations } from 'vuex'//引入mapMutations

export default Vue.extend({
  methods: {
    ...mapMutations(['updateAge', 'updateUsername', 'update'])//对象展开运算符直接拿到updateUsername
  },
  computed: {
    age(){
      return this.$store.state.age
    },
    username(){
      return this.$store.state.username
    }
  }
})
</script>

<style scoped>

</style>

